<?php

/**
 * @Author: king
 * @Date:   2019-05-04 17:01:32
 * @Last Modified by:   king
 * @Last Modified time: 2019-05-30 14:35:04
 */
namespace App\Models\Api;
use App\Exceptions\ApiException;
use App\Models\Api\Base;
use Cache;

class LanmeiCounselorInfo extends Base
{
    protected $table = 'counselor_info';

    public function saveInfo($data = [], $id = [])
    {
        if (empty($id)) {
            try {
                $re = $this->insert($data);
            } catch (\Exception $e) {
                throw new ApiException('认证信息保存失败', config('code.error'));
            }
        } else {
            try {
                $re = $this->insert($data, $id);
            } catch (\Exception $e) {
               throw new ApiException('认证信息保存失败', config('code.error'));
            }
        }

        return $re;
    }


    /**
     * 获取用户认证审核状态
     * @param int $uid
     * @return array|bool|false|mixed|\PDOStatement|string|\think\Model
     */
    public function getAuthInfo($uid = 0)
    {
        $where = ['uid' => $uid];
        try {

            $data = $this->where($where)->orderBy('id', 'DESC')->first();

            $data = json_decode(json_encode($data, true), true);
        } catch (\Exception $e) {
            throw new ApiException('获取咨询师认证信息失败', config('code.error'));
        }

        return $data;
    }
}
